﻿<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>文本内容查看</title>
    <link rel="stylesheet" type="text/css" th:href="@{/bootstrap/css/bootstrap.min.css}"/>
    <script type="text/javascript" th:src="@{/jquery.min.js}"></script>
</head>
<body>
<div class="container-fluid" style="margin-top: 30px;">
    <div class="row">
        <div class="col-md-11" style="font-size: 20px;">
            <b>特别说明：只可查看文本文件内容！</b>
        </div>
        <div class="col-md-1">
            <button class="btn btn-danger" onclick="window.close();">关闭</button>
            &nbsp;&nbsp;&nbsp;
            <button class="btn btn-success" onclick="saveContent();">保存</button>
        </div>
    </div>
    <div class="row" style="text-align: center">
        <div class="col-md-12">
            <textarea th:text="${content}" id="content" class="form-control" rows="30" style="font-size: 16px;"></textarea>
        </div>
    </div>
</div>
<script type="text/javascript" th:inline="javascript">
    var ctx = [[@{/}]];ctx = ctx.substr(0, ctx.length - 1);<!--获取项目根路径-->
    function saveContent(){
        var content = $("#content").val();
        var dirId = [[${dirId}]];
        $.ajax({
            type: "post",
            url: ctx + "/file/content",
            data: {
                dirId:dirId,
                content: content
            },
            dataType: "text",
            async: false,
            success: function (data) {
                alert("保存成功！");
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.responseText);
            }
        });
    }
</script>
</body>
</html>











